var adnet_lib = {
	debug_key: 0,
	timeout_id: null,
	timeout_id_balloon: null,/* Add by dungnt@peacesoft.net - 02/05/2012 */
	rich_media_theme_path: 'http://s0.adnet.vn/img/media/',
	is_load_css: false,
	ref: null,
	is_poped: false,
	pop_data: null,
	ads_data: null,
	is_load_widget: false,
	/** inserted by thoanhv; build RM iTVC*/
	is_rmmin: 0,
	delay: 0,
	config_rm: Array(),
	/** end RM iTVC*/
	init_ref: function() {
		if (!adnet_lib.ref) {
			try {
				if(window != window.top) {
					adnet_lib.ref = document.referrer;
				} else {
					adnet_lib.ref = location.href;
				}
			/*adnet_lib.ref = parent && parent.location.href ? parent.location.href : location.href;*/
			} catch(error)  {
				adnet_lib.ref = location.href;
			}
		}
	},
	reload_widget: function(widget_id) {
		adnet_lib.load_ex_js('http://widget.adnet.vn/js/js.php?widget_id=' + widget_id);
	},
	load_ex_js: function(url) {
		var ga = document.createElement('script');
		ga.type = 'text/javascript';
		ga.async = true;
		ga.src = url;
		var s = document.getElementsByTagName('script')[0];
		s.parentNode.insertBefore(ga, s);
	},
	log_imp: function(data) {
		this.init_ref();
		eval('cf = function(a,b,c){return ' + data.check_function + ';}');
		var time = Math.floor((new Date()).getTime()/1000);
		var client_key = cf(data.widget.id, data.widget.id, time);
		var url = 'http://widget.adnet.vn/js/log_imp.php?widget_id=' + data.widget.id + '&server_key=' + data.server_key + '&t=' + time + '&client_key=' + client_key;
		url += '&ref=' + encodeURIComponent(adnet_lib.ref);
		var logImp = document.createElement('iframe');
		logImp.setAttribute('height', '0');
		logImp.setAttribute('width', '0');
		logImp.setAttribute('frameborder', '0');
		logImp.setAttribute('src', url);
		logImp.setAttribute('style', 'display: none !important');
		document.getElementsByTagName('body')[0].appendChild(logImp);
	},
	reg_cdt_popup: function() {
		return false;
		if(arguments.length == 0) return false;
		if(!adnet_lib.is_load_widget) {
			adnet_lib.is_load_widget = true;
			var popUptag = document.createElement('script');
			popUptag.setAttribute('type', 'text/javascript');
			popUptag.setAttribute('src', 'http://media.ichodientuvn.com/webskins/javascripts/cdt_popup.js');
			document.getElementsByTagName('head')[0].appendChild(popUptag);
		}
	},
	bind_json: function(data) {
		if(window.navigator.userAgent.indexOf('MSIE 8') > 0 || window.navigator.userAgent.indexOf('MSIE 7') > 0 || window.navigator.userAgent.indexOf('MSIE 6') > 0) {
			if(!data) return;
			if(!data.is_loaded) {
				jQuery(document).ready(function() {
					data.is_loaded = true;
					adnet_lib.bind_json(data);
				});
				return;
			}
		}
		if(!this.is_load_css) {
			this.is_load_css = true;
			var cssTag = document.createElement('link');
			cssTag.setAttribute('rel', 'stylesheet');
			cssTag.setAttribute('type', 'text/css');
			cssTag.setAttribute('href', 'http://s0.adnet.vn/css/adnet34.css');
			document.getElementsByTagName('head')[0].appendChild(cssTag);
		}
		if(!data || !data.widget) {
			return;
		}

		if(data.items && data.items.length > 0) {
			this.log_imp(data);
		}
		switch(data.widget.data_type) {
			case 1:
				this.bind_json_product(data);
				/*setTimeout('adnet_lib.reload_widget(' + data.widget.id + ')', 150000);*/
				break;
			case 2:
				this.bind_json_banner(data);
				/*setTimeout('adnet_lib.reload_widget(' + data.widget.id + ')', 150000);*/
				break;
			case 3:
				this.bind_json_text(data);
				break;
			case 4:
				this.bind_json_rich_media(data);
				break;
			default:
				break;
		}
		var widget_html = jQuery('#adnet_widget_' + data.widget.id);
		if(!widget_html) return;
		var widget_type = widget_html.attr('type');
		var ws = this.ws(data.widget.size_id);
		var init_sky = widget_html.attr('init_sky');
		if(init_sky != '1') {
			switch(widget_type) {
				case 'skyscraperleft':
					this.skyscraper('adnet_widget_' + data.widget.id, true, ws.h, ws.w);
					widget_html.attr({
						init_sky: '1'
					});
					break;
				case 'skyscraperright':
					this.skyscraper('adnet_widget_' + data.widget.id, false, ws.h, ws.w);
					widget_html.attr({
						init_sky: '1'
					});
					break;
			}
		}
	},
	bind_json_product: function(data) {
		if(!data || !data.items) return;
		var widget = data.widget;
		var widget_html = jQuery('#adnet_widget_' + widget.id);
		
		var ws = this.ws(widget.size_id);
		/* Add by dungnt@peacesoft.net - 03/05/2012 */
		if(widget.adv_type == 5){
			ws.h = 270;
			ws.w = 274;
		}
		/* --- */
		if(ws.h <= 0 || ws.w <= 0) return;
		var i = 0, html = '', item, max_item = 0, len;
		
		/* Add by dungnt@peacesoft.net - 03/05/2012 */

		if(widget.adv_type == 5){
			item = data.items[0];
			var config = {
				item_height_1 : 230,
				item_width_1 : 260,
				item_delay_1 : 15,
				widget_height_1 : 270,
				widget_width_1 : 274,
				display_format_id : 1,
				item_height_2 : 0,
				item_width_2 : 0,
				item_delay_2 : 15,
				widget_height_2 : 0,
				widget_width_2 : 0
			};

			var size = {
				start_height: 0,
				start_width: 0,
				min_rect: '',
				max_rect: '',
				expand_rect: '',
				bottom: 0,
				right: 0,
				start_rect: null
			};

			/*var wd = jQuery(window);*/
			/* switch case from here */
			widget_html.css({
				height: config.widget_height_1,
				width: config.widget_width_1
			});
			widget_html.css({
				'overflow': 'hidden',
				'position': 'fixed',
                                'float' : 'right',
                                '_bottom' : 20,
				'z-index': 1000000001
			});
			widget_html.css({
				bottom: 5,
				right: 5
			});
			widget_html.attr({
				'_widget_id': widget.id,
				data_type: widget.data_type
			});
			widget_html.html('<div adnet="container_balloon" style="background:white; padding: 4px; border: 1px solid #A8A8A8; border-radius: 2px; -moz-box-shadow: 0 0 10px 1px #CCC; -webkit-box-shadow: 0 0 10px 1px #CCC; box-shadow: 0 0 10px 1px #CCC; height: 270px; width: 340px;">'
				+ '<div adnet="control_cotainer_balloon">'
				+ '		<a adnet="logo_balloon" style="display: block; float:left;text-decoration: none; height: 20px; width: 40px; background: url(' + adnet_lib.rich_media_theme_path + 'adnet-widgetHoz.gif) no-repeat top left;" href="http://adnet.vn" target="_blank">&nbsp;</a>'
				+ '		<div adnet="title_balloon" style="font-family: arial; font-size: 11px; color: #333;float:left; line-height: 24px; width: 176px; margin-right: 4px;">\u004D\u1EA1\u006E\u0067\u0020\u0071\u0075\u1EA3\u006E\u0067\u0020\u0063\u00E1\u006F\u0020\u0074\u0072\u1EF1\u0063\u0020\u0074\u0075\u0079\u1EBF\u006E</div>'
				+ '		<a adnet="close_balloon" style="text-decoration: none; float:right; height: 17px; width: 20px; display: block; background: url(' + adnet_lib.rich_media_theme_path + 'close.gif) no-repeat top left; margin-top: 2px;" href="#">&nbsp;</a>'
				+ '		<a adnet="collapse_balloon" style="text-decoration: none; float:right; height: 17px; width: 20px; display: block; background: url(' + adnet_lib.rich_media_theme_path + 'collapse-widgetBot.gif) no-repeat top left; margin-right: 4px; margin-top: 2px;" href="#">&nbsp;</a>'
				+ '</div>'
				+ '<div adnet="content_balloon" style="cursor: pointer; position: absolute; display: block; z-index: 999; overflow: hidden;"></div>'
				+ '</div>');
			widget_html.find('[adnet=close_balloon]').click(function() {
				widget_html.fadeOut('fast', function() {
					jQuery('#adnet_widget_' + widget.id).remove();
				});
				return false;
			});
			var container = widget_html.find('[adnet=container_balloon]');
			var title = widget_html.find('[adnet=title_balloon]');
			var content = widget_html.find('[adnet=content_balloon]');
			var padding_right = 0;
			/*var extension = '';*/
			var collapse = widget_html.find('[adnet=collapse_balloon]');
			container.css('height', config.widget_height_1 - 10);
			container.css('width', config.widget_width_1 - 10);
			content.css('height', config.item_height_1);
			content.css('width', config.item_width_1);
			padding_right = (config.widget_width_1 - config.item_width_1) / 2 - 1;
			content.css('right', padding_right);
			content.css('bottom', padding_right);
			content.attr('_item_id', item.id);
			content.attr('_target_url', item.target_url);
			// export html BEGIN
			max_item = 2;
			len = data.items.length;
			for(i=len; i<max_item;i++) {
				data.items.push({
					id: 0,
					target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
					price: -1,
					description: 'Quảng cáo trên hàng ngàn website',
					title: 'Quảng cáo tại đây',
					img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
				});
			}
			len = data.items.length;
			var multi_tilte = '<marquee behavior="alternate" scrollamount="1" direction="left" width="175">&nbsp;&nbsp;';
			for(i = 0; i < len && i < max_item; i++) {
				item = data.items[i];
				html += '<div class="listitem">'
				+ '	<p class="img-75"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '" target="_blank"><img src="' + item.img_url + '" alt="" /></a></p>'
				+ '	<div class="headingF"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '" target="_blank">' + item.title + '</a></div>'
				+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
				+ '	<p>' + item.description + '</p>'
				+ '	<p class="item-price">' + adnet_lib.format_price(item.price) + '</p>'
				+ '</div>';
				multi_tilte += item.title + '...  ';
			}
			multi_tilte += '</marquee>';
			html = '<div class="itemAdnet">' + html + '</div>';
			// export html END
			content.html(html);
			content.attr('target_url', item.target_url);
			collapse.click(function() {
				jQuery('[adnet=collapse_balloon]').blur();
				if (adnet_lib.timeout_id_balloon) clearTimeout(adnet_lib.timeout_id_balloon);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				var is_content_hide = widget_html.attr('_is_hidden_balloon') == 'yes';
				widget_html.attr('_is_hidden_balloon', is_content_hide ? 'no' : 'yes');

				container = widget_html.find('[adnet=container_balloon]');

				if(!is_content_hide)
				{
					var new_widget_height = config.widget_height_1 - config.item_height_1 - padding_right * 2 + 2;
                                        new_widget_height = new_widget_height == 20 ? new_widget_height + 10 : new_widget_height + 5; /* add for 250x250 */
					widget_html.animate({
						height: new_widget_height
					}, 'slow');
					container.animate({
						height: new_widget_height - 10
					}, 'slow');
					widget_html.find('[adnet=content_balloon]').animate({
						height: 0,
						opacity: 0
					});
					title.html(multi_tilte);
					collapse.css('background-image', 'url(' + adnet_lib.rich_media_theme_path + 'collapse-widgetTop.gif)');
				}	else {
					widget_html.css('height', config.widget_height_1);
					widget_html.animate({
						height: config.widget_height_1
					}, 'fast');
					container.animate({
						height: config.widget_height_1 - 10
					}, 'fast');
					widget_html.find('[adnet=content_balloon]').css('height', config.item_height_1).css('opacity', 100);
					title.html('\u004D\u1EA1\u006E\u0067\u0020\u0071\u0075\u1EA3\u006E\u0067\u0020\u0063\u00E1\u006F\u0020\u0074\u0072\u1EF1\u0063\u0020\u0074\u0075\u0079\u1EBF\u006E');
					collapse.css('background-image', 'url(' + adnet_lib.rich_media_theme_path + 'collapse-widgetBot.gif)');
				}
				return false;
			});
			adnet_lib.timeout_id_balloon = setTimeout('jQuery(\'#adnet_widget_' + widget.id + ' [adnet=collapse_balloon]\').click()', 1000 * config.item_delay_1);
			widget_html.fadeIn('fast');

			widget_html.bind('action_min', function() {
				jQuery(this).css({
					clip: size.min_rect
				});
			}).bind('action_max', function() {
				jQuery(this).css({
					clip: size.max_rect
				});
			}).bind('action_close', function() {
				if (adnet_lib.timeout_id_balloon) clearTimeout(adnet_lib.timeout_id_balloon);
				jQuery(this).fadeOut(function(){
					jQuery(this).remove();
				});
			}).bind('action_expand', function() {
				if (adnet_lib.timeout_id_balloon) clearTimeout(adnet_lib.timeout_id_balloon);
				jQuery(this).css({
					clip: size.expand_rect
				});
			});
			/* click to qc */
			widget_html.find('.widgetCont').html(html);
			widget_html.find('[adnet=item_link]').click(function() {
				var item_link = jQuery(this);
				if(!item_link.attr('count_click'))
				{
					item_link.attr('count_click', 1);
					var cf = null;
					eval('cf = function(a,b,c){return ' + data.check_function + ';}');
					var time = Math.floor((new Date()).getTime()/1000);
					var widget_id = Number(widget.id);
					var item_id = Number(item_link.attr('_id'));
					var client_key = Math.floor(cf(widget_id, item_id, time));
					var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
					+ item_id
					+ '&widget_id=' + widget_id
					+ '&server_key=' + data.server_key
					+ '&client_key=' + client_key
					+ '&t=' + time
					+ '&targetURL=' + encodeURIComponent(jQuery(this).attr('href'))
					+ '&cat_id=0'
					+ '&type=stop'
					+ '&ref=' + encodeURIComponent(adnet_lib.ref || '')
					+ '&debug_key=' + adnet_lib.debug_key;
					var logClick = document.createElement('iframe');
					logClick.setAttribute('height', '0');
					logClick.setAttribute('width', '0');
					logClick.setAttribute('frameborder', '0');
					logClick.setAttribute('src', url);
					logClick.setAttribute('style', 'display: none !important');
					document.getElementsByTagName('body')[0].appendChild(logClick);
				}
				else
				{
					widget_html.attr('count_click', Number(item_link.attr('count_click')) + 1);
				}
				window.open('http://s0.adnet.vn/cn.html?targetURL=' + encodeURIComponent(jQuery(this).attr('href')));
				return false;
			});
			return;
		}
		// end by dungnt

		switch (widget.size_id) {
			case 4: /* 300x250 */
			case 5: /* 250x250 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="big"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceBig">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 6: /* 240x400 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="big"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceBig">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 7: /* 336x280 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="big"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceBig">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 8: /* 300x100 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 1;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++)	 {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span><span class="symbolR"></span>';
				break;

			case 9: /* 468x60 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img55 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span><span class="symbolR"></span>';
				break;
			case 10: /* 120x240 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 1;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li class="no-bdb">'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img65"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 11: /* 728x90 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -2,
						description: 'Quảng cáo nhanh, trả tiền theo hiệu quả',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					/*+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'*/
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span><span class="symbolR"></span>';
				break;
			case 12: /* 160x600 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img65"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 13: /* 120x600 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width:110px; height: 110px;" src="' + item.img_url + '" alt="" /></a></p>'
					/*+ '	<p class="para">' + item.description + '</p>'*/
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 14: /* 300x600 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 4;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img120 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 120px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="big"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceBig">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 15:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 4;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span> <span class="symbolR"></span>';
				break;
			case 16:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 1;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img55 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 55px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span> <span class="symbolR"></span>';
				break;
			case 17:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 1;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 18:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 4;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -2,
						description: 'Quảng cáo nhanh, trả tiền theo hiệu quả',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span> <span class="symbolR"></span>';
				break;
			case 19:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 75px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 20:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 8;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 21:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 1;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li class="no-bdb">'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img65"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 22:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 75px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 23: /* 468 x 160 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 24: /* 200 x 200 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 1;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 75px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 25: /* 668 x 60 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img55 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 55px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span> <span class="symbolR"></span>';
				break;
			case 26: /* 230 x 540 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 4;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 75px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 27:
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 5;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 28: /* 612 x 90 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					/*+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'*/
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span><span class="symbolR"></span>';
				break;
			case 29: /* 180 x 715 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 6;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 65px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 32:/* 990 x 160 add by dungnt 16.05.2012*/
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 4;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li' + (i == 0 ? ' style="padding-left: 10px !important;"' : '') + '>'
					+ '	<h3 class="small" style="padding-bottom: 5px !important;"><a style="font-weight: bold !important;" adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="img110 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 110px; height: 110px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 33:/* 990 x 200 add by dungnt 25.06.2012 */
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 6;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li' + (i == 0 ? ' style="padding-left: 8px !important;"' : '') + '>'
					+ '	<h3 class="small" style="padding-bottom: 5px !important;"><a style="font-weight: bold !important;" adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="img110"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 130px; height: 130px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 34:/* 631 x 90 add by dungnt 11.07.2012*/
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 3;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li>'
					+ '	<p class="img65 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					/*+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'*/
					+ '	<p class="para">' + item.description + '</p>'
					/*+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'*/
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul><span class="symbolB"></span><span class="symbolR"></span>';
				break;
			case 35:/* 320 x 250 add by dungnt 11.07.2012*/
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 2;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -1,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li' + (i == 0 ? ' style="padding-left: 10px !important;"' : '') + '>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="big"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceBig">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
			case 36:/* 300 x 400 add by dungnt 11.07.2012*/
				widget_html.html(ws.template);
				widget_html = jQuery('#adnet_widget_' + widget.id);
				max_item = 4;
				len = data.items.length;
				for(i=len; i<max_item;i++) {
					data.items.push({
						id: 0,
						target_url: 'http://adnet.vn/index.php?portal=advertiser&page=home&tab=account#add_adv',
						price: -2,
						description: 'Quảng cáo trên hàng ngàn website',
						title: 'Quảng cáo tại đây',
						img_url: 'http://s0.adnet.vn/img/adnet_logo_160.png'
					});
				}
				len = data.items.length;
				for(i = 0; i < len && i < max_item; i++) {
					item = data.items[i];
					html += '<li' + (i == 0 ? ' style="padding-left: 10px !important;"' : '') + '>'
					+ '	<p class="img75 fl"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '"><img class="adnet_item_img" style="width: 75px;" src="' + item.img_url + '" alt="" /></a></p>'
					+ '	<h3 class="small"><a adnet="item_link" _id="' + item.id + '" href="' + item.target_url + '">' + item.title + '</a></h3>'
					+ '	<p class="hint">' + adnet_lib.trim_domain(item.target_url) + '</p>'
					+ '	<p class="para">' + item.description + '</p>'
					+ '	<p class="priceSmall">' + adnet_lib.format_price(item.price) + '</p>'
					+ '</li>';
				}
				html = '<ul class="itemNews">' + html + '</ul>';
				break;
		}
		widget_html.find('.widgetCont').html(html);
		widget_html.fadeIn();
		widget_html.find('[adnet=item_link]').click(function() {
			var item_link = jQuery(this);
			if(!item_link.attr('count_click'))
			{
				item_link.attr('count_click', 1);
				var cf = null;
				eval('cf = function(a,b,c){return ' + data.check_function + ';}');
				var time = Math.floor((new Date()).getTime()/1000);
				var widget_id = Number(widget.id);
				var item_id = Number(item_link.attr('_id'));
				var client_key = Math.floor(cf(widget_id, item_id, time));
				var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
				+ item_id
				+ '&widget_id=' + widget_id
				+ '&server_key=' + data.server_key
				+ '&client_key=' + client_key
				+ '&t=' + time
				+ '&targetURL=' + encodeURIComponent(jQuery(this).attr('href'))
				+ '&ref=' + encodeURIComponent(adnet_lib.ref)
				+ '&cat_id=0'
				+ '&type=stop'
				+ '&debug_key=' + adnet_lib.debug_key;
				var logClick = document.createElement('iframe');
				logClick.setAttribute('height', '0');
				logClick.setAttribute('width', '0');
				logClick.setAttribute('frameborder', '0');
				logClick.setAttribute('src', url);
				logClick.setAttribute('style', 'display: none !important');
				document.getElementsByTagName('body')[0].appendChild(logClick);
			}
			else
			{
				widget_html.attr('count_click', Number(item_link.attr('count_click')) + 1);
			}
			window.open('http://s0.adnet.vn/cn.html?targetURL=' + encodeURIComponent(jQuery(this).attr('href')));
			return false;
		});
		widget_html;
	},
	bind_json_banner: function(data) {
		if(!data || !data.items) return;
		var widget = data.widget;
		var widget_html = jQuery('#adnet_widget_' + widget.id);
		if(data.items.length <= 0) {
			widget_html.remove();
			return;
		}

		var item = data.items[0];
		var ws = this.ws(widget.size_id);
		widget_html.css({
			height: ws.h,
			width: ws.w,
			position: 'relative',
			overflow: 'hidden',
			zIndex: 1000001
		});
		widget_html.addClass('adnet_reset');

		var html_content = '';
		if(item.img_url.indexOf('.swf') > 0) {
			widget_html.css('background-color', 'grey');
			html_content = '<div adnet="item" type="swf" target_url="' + item.target_url + '"><object  width="' + ws.w + '" height="' + ws.h + '"><param value="' + item.img_url + '" name="movie"><param value="high" name="quality"><param value="always" name="allowScriptAccess"><param name="wmode" value="transparent"><param name="flashVars"><embed width="' + ws.w + '" height="' + ws.h + '" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" quality="high" src="' + item.img_url + '"></object></div>';
		} else {
			html_content = '<a adnet="item" title="' + item.title.replace('"', '&quot;') + ' (' + adnet_lib.trim_domain(item.target_url) + ')" type="img" target_url="' + item.target_url + '" href="' + item.target_url + '" target="_blank"><img style="height: ' + ws.h + 'px; width: ' + ws.w + 'px;" src="' + item.img_url + '" /></a>';
		}
		var adnet_content = '<a href="http://adnet.vn" style="color:white;" target="_blank">Quảng cáo bởi Adnet</a>';
		html_content = '<ul style="height: ' + ws.h + 'px; width: ' + ws.w + 'px;"><li style="position: relative;height: ' + ws.h + 'px; width: ' + ws.w + 'px;">' + html_content + '<ul adnet="adnet" style="position: absolute; display:none; position: absolute; bottom: 0px; left: 0px; "><li style="padding: 5px 10px;background-color:red; float:left; font-family: arial; font-size: 11px; line-height: 14px;">' + adnet_content + '</li></ul></li></ul>';
		widget_html.append(html_content);
		widget_html.fadeIn('fast');

		widget_html.find('li:first').hover(function() {
			jQuery(this).find('[adnet=adnet]').fadeIn('fast');
		}, function() {
			jQuery(this).find('[adnet=adnet]').fadeOut();
		});
					
		widget_html.find('[adnet=item]').click(function() {
			widget_html = jQuery('#adnet_widget_' + widget.id);
			if(!widget_html.attr('count_click'))
			{
				widget_html.attr('count_click', 1);
				var cf = null;
				eval('cf = function(a,b,c){return ' + data.check_function + ';}');
				var time = Math.floor((new Date()).getTime()/1000);
				var widget_id = Number(widget.id);
				var item_id = Number(item.id);
				var client_key = Math.floor(cf(widget_id, item_id, time));
				var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
				+ item_id
				+ '&widget_id=' + widget_id
				+ '&server_key=' + data.server_key
				+ '&client_key=' + client_key
				+ '&t=' + time
				+ '&targetURL=' + encodeURIComponent(jQuery(this).attr('target_url'))
				+ '&cat_id=0'
				+ '&ref=' + encodeURIComponent(adnet_lib.ref)
				+ '&type=stop'
				+ '&debug_key=' + adnet_lib.debug_key;
				var logClick = document.createElement('iframe');
				logClick.setAttribute('height', '0');
				logClick.setAttribute('width', '0');
				logClick.setAttribute('frameborder', '0');
				logClick.setAttribute('src', url);
				logClick.setAttribute('style', 'display: none !important');
				document.getElementsByTagName('body')[0].appendChild(logClick);
			}
			else
			{
				widget_html.attr('count_click', Number(widget_html.attr('count_click')) + 1);
			}
			//Trường hợp cho banner là ảnh thường
			var target_url = encodeURIComponent(jQuery(this).attr('href'));
			//Trường hợp banner là flash >> Nếu targer_url có chứa '#ads_adnet' ~ (%23ads_adnet) nghĩa là mặc định sử dụng function add trong code flash, còn nếu nhập targer_url thì là bình thường
			if(item.img_url.indexOf('.swf') > 0){
				target_url = encodeURIComponent(widget_html.find('[adnet=item]').attr('target_url'));				
			}
			
			if(target_url.indexOf(encodeURIComponent('#ads_adnet')) == -1)//Không phải gọi từ flash thì sẽ gọi ở đây
				window.open('http://s0.adnet.vn/cn.html?targetURL=' + target_url);
			return false;
		});
	},
	bind_json_rich_media: function(data) {
		var widget = data.widget;
		var widget_html = jQuery('#adnet_widget_' + widget.id);
		if(!widget_html) return;
		if(!data.items || data.items.length <= 0) {
			widget_html.remove();
			return;
		}
		var item = data.items[0];
		var config = data.widget.item_rich_media_config;
		if(!data.widget.item_rich_media_config) {
			return;
		}

		var size = {
			start_height: 0,
			start_width: 0,
			min_rect: '',
			max_rect: '',
			expand_rect: '',
			bottom: 0,
			right: 0,
			start_rect: null
		};

		var wd = jQuery(window);
		var html = '';
		switch(config.display_format_id) {
			case 1:
				widget_html.css({
					height: config.widget_height_1,
					width: config.widget_width_1
				});
				widget_html.css({
					'overflow': 'hidden',
					'position': 'fixed',
                                        'float' : 'right',
                                        'z-index': 1000000001,
					'-webkit-transform': 'scale(1)'
				});
				widget_html.css({
					bottom: 5,
					right: 5
				});
				widget_html.attr({
					'_widget_id': widget.id,
					data_type: widget.data_type
				});
				if(widget.item_rich_media_config.display_format_id == 2) {
					/* no adnet container */
					widget_html.css({
						height: 230,
						width: 260
					});
					widget_html.html(adnet_lib.gen_html_media_org(item.img_url, 230, 260, item.title, widget.id, item.target_url));
					widget_html.find('[adnet=content]').mousedown(function() {
						widget_html = jQuery('#adnet_widget_' + widget.id);
						if(!widget_html.attr('count_click'))
						{
							widget_html.attr('count_click', 1);
							var cf = null;
							eval('cf = function(a,b,c){return ' + data.check_function + ';}');
							var time = Math.floor((new Date()).getTime()/1000);
							var widget_id = Number(widget.id);
							var item_id = Number(item.id);
							var client_key = Math.floor(cf(widget.id, item.id, time));
							var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
							+ item_id
							+ '&widget_id=' + widget_id
							+ '&server_key=' + data.server_key
							+ '&client_key=' + client_key
							+ '&t=' + time
							+ '&targetURL=' + encodeURIComponent(item.target_url)
							+ '&cat_id=0'
							+ '&type=stop'
							+ '&debug_key=' + adnet_lib.debug_key;
							var logClick = document.createElement('iframe');
							logClick.setAttribute('height', '0');
							logClick.setAttribute('width', '0');
							logClick.setAttribute('frameborder', '0');
							logClick.setAttribute('src', url);
							logClick.setAttribute('style', 'display: none !important');
							document.getElementsByTagName('body')[0].appendChild(logClick);
						}
						else
						{
							widget_html.attr('count_click', Number(widget_html.attr('count_click')) + 1);
						}
						return true;
					});
					widget_html.fadeIn('fast');
					return;
				}
				
				widget_html.html('<div adnet="container" style="background:white; padding: 4px; border: 1px solid #A8A8A8; border-radius: 2px; -moz-box-shadow: 0 0 10px 1px #CCC; -webkit-box-shadow: 0 0 10px 1px #CCC; box-shadow: 0 0 10px 1px #CCC; height: 270px; width: 340px;">'
					+ '<div adnet="control_cotainer">'
					+ '		<a adnet="logo" style="display: block; float:left;text-decoration: none; height: 20px; width: 40px; background: url(' + adnet_lib.rich_media_theme_path + 'adnet-widgetHoz.gif) no-repeat top left;" href="http://adnet.vn" target="_blank">&nbsp;</a>'
					+ '		<div adnet="title" style="font-family: arial; font-size: 11px; color: #333;float:left; line-height: 24px; width: 176px; margin-right: 4px;">\u004D\u1EA1\u006E\u0067\u0020\u0071\u0075\u1EA3\u006E\u0067\u0020\u0063\u00E1\u006F\u0020\u0074\u0072\u1EF1\u0063\u0020\u0074\u0075\u0079\u1EBF\u006E</div>'
					+ '		<a adnet="close" style="text-decoration: none; float:right; height: 17px; width: 20px; display: block; background: url(' + adnet_lib.rich_media_theme_path + 'close.gif) no-repeat top left; margin-top: 2px;" href="#">&nbsp;</a>'
					+ '		<a adnet="collapse" style="text-decoration: none; float:right; height: 17px; width: 20px; display: block; background: url(' + adnet_lib.rich_media_theme_path + 'collapse-widgetBot.gif) no-repeat top left; margin-right: 4px; margin-top: 2px;" href="#">&nbsp;</a>'
					+ '</div>'
					+ '<div adnet="content" style="border: 1px solid #A8A8A8; cursor: pointer; position: absolute; display: block; z-index: 999; overflow: hidden;"></div>'
					+ '</div>');
				widget_html.find('[adnet=close]').click(function() {
					widget_html.fadeOut('fast', function() {
						jQuery('#adnet_widget_' + widget.id).remove();
					});
					return false;
				});
				var container = widget_html.find('[adnet=container]');
				var title = widget_html.find('[adnet=title]');
				var content = widget_html.find('[adnet=content]');
				var padding_right = 0;
				var extension = '';
				var collapse = widget_html.find('[adnet=collapse]');
				container.css('height', config.widget_height_1 - 10);
				container.css('width', config.widget_width_1 - 10);
				content.css('height', config.item_height_1);
				content.css('width', config.item_width_1);
				padding_right = (config.widget_width_1 - config.item_width_1) / 2 - 1;
				content.css('right', padding_right);
				content.css('bottom', padding_right);
				content.attr('_item_id', item.id);
				content.attr('_target_url', item.target_url);

				extension = adnet_lib.get_url_extension(config.item_source_1);
				switch(extension) {
					case 'swf':
						html = '<object height="' + config.item_height_1 + '" width="' + config.item_width_1 + '">';
						html += '<param name="movie" value="' + config.item_source_1 + '" />';
						html += '<param name="quality" value="high" />';
						html += '<param name="allowScriptAccess" value="always" />';
						html += '<param name="flashvars" value="widget_id=' + widget.id + '" />';
						html += '<param value="transparent" name="wmode" />';
						html += '<embed src="' + config.item_source_1 + '" height="' + config.item_height_1 + '" width="' + config.item_width_1 + '"';
						html += ' flashvars="widget_id=' + widget.id + '" allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer">';
						html += '</embed>';
						html += '</object>';
						break;
					case 'jpg':
					case 'jpeg':
					case 'gif':
					case 'png':
						html = '<a href="' + item.target_url + '" target="_blank"><img title="' + item.title.replace('"', '') + '" src="' + config.item_source_1 + '" /></a>';
						break;
				}
				content.html(html);
				content.attr('target_url', item.target_url);
				collapse.click(function() {
					jQuery('[adnet=collapse]').blur();
					if (adnet_lib.timeout_id) clearTimeout(adnet_lib.timeout_id);
					widget_html = jQuery('#adnet_widget_' + widget.id);
					var is_content_hide = widget_html.attr('_is_hidden') == 'yes';
					widget_html.attr('_is_hidden', is_content_hide ? 'no' : 'yes');

					container = widget_html.find('[adnet=container]');

					if(!is_content_hide)
					{
						var new_widget_height = config.widget_height_1 - config.item_height_1 - padding_right * 2 + 2;
                                                new_widget_height = new_widget_height == 20 ? new_widget_height + 10 : new_widget_height + 5; /* add for 250x250 */
						widget_html.animate({
							height: new_widget_height
						}, 'slow');
						container.animate({
							height: new_widget_height - 10
						}, 'slow');
						widget_html.find('[adnet=content]').animate({
							height: 0,
							opacity: 0
						});
						title.html('<marquee behavior="alternate" scrollamount="4" direction="left" width="175">' + item.title + '</marquee>');
						collapse.css('background-image', 'url(' + adnet_lib.rich_media_theme_path + 'collapse-widgetTop.gif)');
					}	else {
						//widget_html.css('height', config.widget_height_1);
						widget_html.animate({
							height: config.widget_height_1
						}, 'fast');
						container.animate({
							height: config.widget_height_1 - 10
						}, 'fast');
						widget_html.find('[adnet=content]').css('height', config.item_height_1).css('opacity', 100);
						title.html('\u004D\u1EA1\u006E\u0067\u0020\u0071\u0075\u1EA3\u006E\u0067\u0020\u0063\u00E1\u006F\u0020\u0074\u0072\u1EF1\u0063\u0020\u0074\u0075\u0079\u1EBF\u006E');
						collapse.css('background-image', 'url(' + adnet_lib.rich_media_theme_path + 'collapse-widgetBot.gif)');
					}
					return false;
				});
                                adnet_lib.timeout_id = setTimeout('jQuery(\'#adnet_widget_' + widget.id + ' [adnet=collapse]\').click()', 1000 * config.item_delay_1);
				content.mousedown(function() {
					if(item.id == 14300 || item.id == 14272)
						adnet_lib.rm_click(widget.id);
					if (adnet_lib.timeout_id) clearTimeout(adnet_lib.timeout_id);
				});
				widget_html.fadeIn('fast');

				widget_html.bind('action_min', function() {
					jQuery(this).css({
						clip: size.min_rect
					});
				}).bind('action_max', function() {
					jQuery(this).css({
						clip: size.max_rect
					});
				}).bind('action_close', function() {
					if (adnet_lib.timeout_id) clearTimeout(adnet_lib.timeout_id);
					jQuery(this).fadeOut(function(){
						jQuery(this).remove();
					});
				}).bind('action_expand', function() {
					if (adnet_lib.timeout_id) clearTimeout(adnet_lib.timeout_id);
					jQuery(this).css({
						clip: size.expand_rect
					});
				}).bind('action_click', function() {
					widget_html = jQuery('#adnet_widget_' + widget.id);
					if(!widget_html.attr('count_click'))
					{
						widget_html.attr('count_click', 1);
						var cf = null;
						eval('cf = function(a,b,c){return ' + data.check_function + ';}');
						var time = Math.floor((new Date()).getTime()/1000);
						var widget_id = Number(widget.id);
						var item_id = Number(item.id);
						var client_key = Math.floor(cf(widget_id, item_id, time));
						var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
						+ item_id
						+ '&widget_id=' + widget_id
						+ '&server_key=' + data.server_key
						+ '&client_key=' + client_key
						+ '&t=' + time
						+ '&targetURL=' + encodeURIComponent(item.target_url)
						+ '&cat_id=0'
						+ '&type=stop'
						+ '&debug_key=' + adnet_lib.debug_key;
						var logClick = document.createElement('iframe');
						logClick.setAttribute('height', '0');
						logClick.setAttribute('width', '0');
						logClick.setAttribute('frameborder', '0');
						logClick.setAttribute('src', url);
						logClick.setAttribute('style', 'display: none !important');
						document.getElementsByTagName('body')[0].appendChild(logClick);
					}
					else
					{
						widget_html.attr('count_click', Number(widget_html.attr('count_click')) + 1);
					}
					return true;
				});
				return;
			/*size.start_height = 230;
				size.start_width = 260;
				size.min_rect = 'rect(200px, 260px, 230px, 0px)';
				size.max_rect = 'rect(0px, 260px, 230px, 0px)';
				adnet_lib.timeout_id = setTimeout('jQuery(\'#adnet_widget_' + widget.id + '\').trigger(\'action_min\')', 15000);
				break;*/
			case 2:
                size.start_height = 400;
                size.start_width = 500;
                size.min_rect = 'rect(0px,500px, 250px, 250px)';
                size.max_rect = 'rect(0px, 500px, 400px, 0px)';
                size.expand_rect = 'rect(0px, 500px, 300px, 0px)';
                //adnet_lib.timeout_id = setTimeout('jQuery(\'#adnet_widget_' + widget.id + '\').trigger(\'action_close\')', 20000);
                size.start_rect = size.max_rect;
                break;
			case 3: /* Page take-over banner */
				size.start_height = 500;
				size.start_width = 800;
				size.min_rect = 'rect(470px, 800px, 500px, 540px)';
				size.max_rect = 'rect(270px, 800px, 500px, 540px)';
				size.expand_rect = 'rect(0px, 800px, 500px, 0px)';
				adnet_lib.timeout_id = setTimeout('jQuery(\'#adnet_widget_' + widget.id + '\').trigger(\'action_min\')', 30000);
				size.start_rect = size.expand_rect;
				break;
			case 4: /* over the page banner */
				break;
			case 5: /* background banner left */
				size.start_height = 600;
				size.start_width = 120;
				size.bottom = (wd.height() - 600) / 2;
				size.right = wd.width();
				size.right = size.right > 1000 ? (size.right - 120 - 5) : -1;
				break;
			case 6: /* standard iTVC banner */
				size.start_height = 246;
				size.start_width = 370;
				size.min_rect = 'rect(216px, 370px, 246px, 110px)';
				size.max_rect = 'rect(0px, 370px, 246px, 0px)';
				adnet_lib.timeout_id = setTimeout('jQuery(\'#adnet_widget_' + widget.id + '\').trigger(\'action_min\')', 30000);
				break;
			case 7: /* Page take over iTVC banner */
				size.start_height = config.item_height_1;
				size.start_width = config.item_width_1;
				size.min_rect = 'rect(47px, ' + size.start_width + 'px, ' + size.start_height + 'px, 540px)';
				size.max_rect = 'rect(254px, ' + size.start_width + 'px, ' + size.start_height + 'px, 430px)';
				adnet_lib.timeout_id = setTimeout('jQuery(\'#adnet_widget_' + widget.id + '\').trigger(\'action_max\')', (config.item_delay_1 * 1000));				
				size.start_rect = size.expand_rect;
				break;		
			case 71: /* Page take over iTVC banner */
				if(widget.id == 8374){//Fix size for yume.vn
					config.item_width_2 = 260;
					config.item_height_2 = 230;
				}			
				adnet_lib.config_rm[0] = {count_down: config.count_down, text_color: jQuery.trim(config.text_color), item_id: config.item_id, widget_id: widget.id, width: config.item_width_1, height: config.item_height_1, source: config.item_source_1, delay: config.item_delay_1, margin: '0'};
				adnet_lib.config_rm[1] = {count_down: config.count_down, text_color: jQuery.trim(config.text_color), item_id: config.item_id, widget_id: widget.id, width: config.item_width_2, height: config.item_height_2, source: config.item_source_2, delay: config.item_delay_2, margin: '0 auto'};
				if(widget.id == 14852 || widget.id == 14853 || widget.id == 14854 || widget.id == 5014 || widget.id == 2948 || widget.id == 5098 || widget.id == 3797){//mp3.zing.vn, vnexpress.net, ngoisao.net, megafun.vn, chodientu.vn, baodatviet.vn, beponline.com.vn, s0.adnet.vn (3075)								
					adnet_lib.run_backward(adnet_lib.config_rm);
				}
				else{
					adnet_lib.run_default(adnet_lib.config_rm);
				}
				
				widget_html.bind('action_click', function() {
					widget_html = jQuery('#adnet_widget_' + widget.id);
					if(!widget_html.attr('count_click'))
					{
						widget_html.attr('count_click', 1);
						var cf = null;
						eval('cf = function(a,b,c){return ' + data.check_function + ';}');
						var time = Math.floor((new Date()).getTime()/1000);
						var widget_id = Number(widget.id);
						var item_id = Number(item.id);
						var client_key = Math.floor(cf(widget_id, item_id, time));
						var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
						+ item_id
						+ '&widget_id=' + widget_id
						+ '&server_key=' + data.server_key
						+ '&client_key=' + client_key
						+ '&t=' + time
						+ '&targetURL=' + encodeURIComponent(item.target_url)
						+ '&cat_id=0'
						+ '&type=stop'
						+ '&debug_key=' + adnet_lib.debug_key;
						var logClick = document.createElement('iframe');
						logClick.setAttribute('height', '0');
						logClick.setAttribute('width', '0');
						logClick.setAttribute('frameborder', '0');
						logClick.setAttribute('src', url);
						logClick.setAttribute('style', 'display: none !important');
						document.getElementsByTagName('body')[0].appendChild(logClick);
					}
					else
					{
						widget_html.attr('count_click', Number(widget_html.attr('count_click')) + 1);
					}
					return true;
				});
				
				return;
			case 8: /* background banner right */
				size.start_height = 600;
				size.start_width = 120;
				size.bottom = (wd.height() - 600) / 2;
				size.right = wd.width();
				size.right = size.right > 1000 ? 5 : -1;
				break;
			case 9: /* Insider ads */
				size.start_height = adnet_lib.ws(widget.size_id);
				size.start_width = size.start_height.w;
				size.start_height = size.start_height.h;
				break;

		}
		if(size.right < 0) return;

		var html_content = adnet_lib.gen_html_media({
			widget_id: widget.id,
			title: item.title,
			target_url: item.target_url,
			source: item.img_url,
			height: size.start_height,
			width: size.start_width
		});
		widget_html.css({
			'overflow': 'hidden',
			height: size.start_height,
			width: size.start_width
		});
		if(config.display_format_id != 9) {
			widget_html.css({
				'position': 'fixed',
				'z-index': 1000000001,
				bottom: size.bottom,
				right: size.right
			});
		}

		if(size.start_rect)
			widget_html.css({
				clip: size.start_rect
			});
		widget_html.attr({
			display_format_id: config.display_format_id,
			data_type: widget.data_type,
			widget_id: widget.id
		});
		widget_html.html(html_content);
		widget_html.fadeIn('fast');

		widget_html.bind('action_min', function() {
			jQuery(this).css({
				clip: size.min_rect
			});
		}).bind('action_max', function() {
			jQuery(this).css({
				clip: size.max_rect
			});
		}).bind('action_close', function() {
			if (adnet_lib.timeout_id) clearTimeout(adnet_lib.timeout_id);
			jQuery(this).fadeOut(function(){
				jQuery(this).remove();
			});
		}).bind('action_expand', function() {
			if (adnet_lib.timeout_id) clearTimeout(adnet_lib.timeout_id);
			jQuery(this).css({
				clip: size.expand_rect
			});
		}).bind('action_click', function() {
			widget_html = jQuery('#adnet_widget_' + widget.id);
			if(!widget_html.attr('count_click'))
			{
				widget_html.attr('count_click', 1);
				var cf = null;
				eval('cf = function(a,b,c){return ' + data.check_function + ';}');
				var time = Math.floor((new Date()).getTime()/1000);
				var widget_id = Number(widget.id);
				var item_id = Number(item.id);
				var client_key = Math.floor(cf(widget_id, item_id, time));
				var url = 'http://widget.adnet.vn/js/log_c.php?item_id='
				+ item_id
				+ '&widget_id=' + widget_id
				+ '&server_key=' + data.server_key
				+ '&client_key=' + client_key
				+ '&t=' + time
				+ '&targetURL=' + encodeURIComponent(item.target_url)
				+ '&cat_id=0'
				+ '&type=stop'
				+ '&debug_key=' + adnet_lib.debug_key;
				var logClick = document.createElement('iframe');
				logClick.setAttribute('height', '0');
				logClick.setAttribute('width', '0');
				logClick.setAttribute('frameborder', '0');
				logClick.setAttribute('src', url);
				logClick.setAttribute('style', 'display: none !important');
				document.getElementsByTagName('body')[0].appendChild(logClick);
			}
			else
			{
				widget_html.attr('count_click', Number(widget_html.attr('count_click')) + 1);
			}
			return true;
		});
		return;
	},
	get_url_extension: function(url) {
		url = url.toLowerCase();
		url = url.split('.');
		return url[url.length - 1];
	},
	draw_widget_container: function(data) {
		var widget = data.widget;
		var widget_html = jQuery('#adnet_widget_' + widget.id);
		if(!widget_html || widget_html.length == 0) return;
		widget_html.addClass('adnet_size_' + widget.size_id);

		widget_html.attr('widget_id', widget.id);
		widget_html.attr('cat_id', widget.cat_id);
		widget_html.attr('server_key', data.server_key);
		widget_html.attr('check_function', data.check_function);

		if(widget.data_type == 4) {
			return;
		}


		var ws = this.ws(widget.size_id);
		if(ws.h <= 0 || ws.w <= 0) return;
		if(widget.display_type == 0) {
			jQuery('<div class="_adnet" style="position:absolute; line-height: 13px; bottom: 0px;left: 0px; background-color: #D30000; padding:5px 10px; display: none; z-index: 4; width: ' + (ws.w - 22) + 'px;"><a href="http://adnet.vn" style="color:white; text-decoration: none; font-family: arial; font-size: 10px; font-weight: normal;" target="_blank">Máº¡ng quáº£ng cÃ¡o trá»±c tuyáº¿n Adnet</a></div>').appendTo(widget_html);
			widget_html.hover(function() {
				widget_html.find('div._adnet').fadeIn('fast');
			}, function() {
				widget_html.find('div._adnet').fadeOut();
			});
			if(widget.data_type == 1) {
				widget_html.css({
					height: ws.h - 2,
					width: ws.w - 2,
					display: 'block',
					position: 'relative',
					overFlow: 'hidden',
					border: 'solid 1px #6ea500'
				});
				jQuery('<div class="_inner" style="height: ' + (ws.h - 2) + 'px; width: ' + (ws.w - 2) + 'px; overflow: hidden;"></div>').insertBefore(widget_html.find('div._adnet'));
			} else if (widget.data_type == 2) {
				widget_html.css({
					height: ws.h,
					width: ws.w,
					display: 'block',
					position: 'relative',
					overFlow: 'hidden'
				});
				jQuery('<div class="_inner" style="height: ' + (ws.h) + 'px; width: ' + (ws.w) + 'px; overflow: hidden;"></div>').insertBefore(widget_html.find('div._adnet'));
				jQuery('<div class="_over" style="height: ' + (ws.h) + 'px; width: ' + (ws.w) + 'px; overflow: hidden; position: absolute; z-index: 3; background-color: black; top: 0px; left: 0px;"></div>').insertBefore(widget_html.find('div._adnet'));
				widget_html.find('div._over').css({
					opacity: 0,
					cursor: 'pointer'
				}).click(function() {
					adnet_lib.click(data.items[0].id, widget.id, widget.cat_id, data.server_key, data.check_function, data.items[0].target_url);
					return false;
				});
			}
		}


	},
	bind_json_text: function(data) {

	},
	click: function(item_id, widget_id, cat_id, server_key, check_function, target_url) {
		var cf = null;
		eval('cf = function(a,b,c){return ' + check_function + ';}');
		var time = (new Date()).getTime()/1000;
		var client_key = cf(widget_id, item_id, time);
		var c_name = 'w' + widget_id + 'i' + item_id;
		if (this.getCookie(c_name) == '1') {
			window.open('http://s0.adnet.vn/cn.html?targetURL=' + encodeURIComponent(target_url));
		} else {
			this.setCookie(c_name, '1', 1);
			window.open('http://widget.adnet.vn/js/log_c.php?item_id=' + item_id + '&widget_id=' + widget_id + '&server_key=' + server_key + '&client_key=' + client_key + '&t=' + time + '&targetURL=' + encodeURIComponent(target_url) + '&cat_id=' + cat_id);
		}
	},
	setCookie: function(c_name,value,minute)
	{
		var exdate=(new Date()).getTime() + minute * 60000;
		exdate = new Date(exdate);
		var c_value=escape(value) + ((exdate==null) ? "" : "; expires="+exdate.toUTCString());
		document.cookie=c_name + "=" + c_value + "; path=/; domain=";
	},
	getCookie: function(c_name)
	{
		var i,x,y,ARRcookies=document.cookie.split(";");
		for (i=0;i<ARRcookies.length;i++)
		{
			x = ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
			x = x ? x.replace(/\s+/g, '') : '';
			y = ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
			if (x == c_name)
			{
				return unescape(y);
			}
		}
		return null;
	},
	format_price: function(n) {
		if (typeof(n) == 'undefined' || n == null /*|| n == '-1'*/ || n == '') {
			return '&nbsp;';
		}
		n = Number(n);
		if (n == -1) {//Dùng riêng cho quảng cáo mặc định của Adnet
			return '<span style="font-weight: normal !important;">Quảng cáo nhanh, trả tiền theo hiệu quả</span>';
		}
		if (n < 0) {
			return '&nbsp;';
		}
		if (n == 0) {
			return 'Giá: liên hệ';
		}
		n = (n + '').replace(/\.|,/g , '');
		n =  n.split('').reverse().join('').replace(/(.{3})/g, '$1.').split('').reverse().join('');
		if (n.charAt(0) == '.') n = n.substr(1);
		return n + '&#8363;';
	},
	ws: function(id) {
		var size = {
			w: 0,
			h: 0
		};
		switch(id) {
			case 4:
				size = {
					w: 300,
					h: 250,
					template: '<div class="widgetAdnet wh300x250"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 5:
				size = {
					w: 250,
					h: 250,
					template: '<div class="widgetAdnet wh250x250"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span> </div>'
				};
				break;
			case 6:
				size = {
					w: 240,
					h: 400,
					template: '<div class="widgetAdnet wh240x400"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span> </div>'
				};
				break;
			case 7:
				size = {
					w: 336,
					h: 280,
					template: '<div class="widgetAdnet wh336x280"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span> </div>'
				};
				break;
			case 8:
				size = {
					w: 300,
					h: 100,
					template: '<div class="wh300x100 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank" class="QCVer">&nbsp;</a></div></div></div><div class="widgetCont"><span class="symbolB"></span> <span class="symbolR"></span> </div></div>'
				};
				break;
			case 9:
				size = {
					w: 468,
					h: 60,
					template: '<div class="wh468x60 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a class="QCVer" href="http://adnet.vn" target="_blank">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 10:
				size = {
					w: 120,
					h: 240,
					template: '<div class="widgetAdnet wh120x240"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetSmall">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span><span class="symbolR"></span></div>'
				};
				break;
			case 11:
				size = {
					w: 728,
					h: 90,
					template: '<div class="wh728x90 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank" class="QCVer">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 12:
				size = {
					w: 160,
					h: 600,
					template: '<div class="widgetAdnet wh160x600"><div class="headingWidget"><div class="bg-adnetSmall"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetSmall">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span> </div>'
				};
				break;
			case 13:
				size = {
					w: 120,
					h: 600,
					template: '<div class="widgetAdnet wh120x600"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetSmall">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span> </div>'
				};
				break;
			case 14:
				size = {
					w: 300,
					h: 600,
					template: '<div class="widgetAdnet wh300x600"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="http://adnet.vn" target="_blank" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 15:
				size = {
					w: 950,
					h: 90,
					template: '<div class="wh950x90 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a class="QCVer" href="http://adnet.vn" target="_blank">&nbsp;</a></div></div></div><div class="widgetCont"><span class="symbolB"></span> <span class="symbolR"></span> </div></div>'
				};
				break;
			case 16:
				size = {
					w: 234,
					h: 60,
					template: '<div class="wh234x60 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a class="QCVer" href="http://adnet.vn" target="_blank">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 17:
				size = {
					w: 180,
					h: 150,
					template: '<div class="widgetAdnet wh180x150"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetBig" href="#">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 18:
				size = {
					w: 970,
					h: 100,
					template: '<div class="wh970x100 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a class="QCVer" href="http://adnet.vn" target="_blank">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 19:
				size = {
					w: 230,
					h: 230,
					template: '<div class="widgetAdnet wh230x230"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetBig" href="#">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 20:
				size = {
					w: 720,
					h: 300,
					template: '<div class="widgetAdnet wh720x300"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="#" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 21:
				size = {
					w: 160,
					h: 300,
					template: '<div class="widgetAdnet wh160x300"><div class="headingWidget"><div class="bg-adnetSmall"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetSmall" href="#">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 22:
				size = {
					w: 200,
					h: 400,
					template: '<div class="widgetAdnet wh200x400"><div class="headingWidget"><div class="bg-adnetSmall"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetBig" href="#">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 23:
				size = {
					w: 468,
					h: 160,
					template: '<div class="widgetAdnet wh468x160"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="#" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 24:
				size = {
					w: 200,
					h: 200,
					template: '<div class="widgetAdnet wh200x200"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetBig" href="#">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 25:
				size = {
					w: 668,
					h: 60,
					template: '<div class="wh668x60 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank" class="QCVer">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 26:
				size = {
					w: 230,
					h: 540,
					template: '<div class="widgetAdnet wh230x540"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetBig" href="http://adnet.vn" target="_blank">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 27:
				size = {
					w: 990,
					h: 100,
					template: '<div class="wh990x100 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank" class="QCVer">&nbsp;</a></div></div></div><div class="widgetCont"><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 28:
				size = {
					w: 612,
					h: 90,
					template: '<div class="wh612x90 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank" class="QCVer">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 29:
				size = {
					w: 180,
					h: 715,
					template: '<div class="widgetAdnet wh180x715"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a class="logoAdnetBig" href="#">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 32:/* add by dungnt 16.5.2012 */
				size = {
					w: 990,
					h: 160,
					template: '<div class="widgetAdnet wh990x160"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="#" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 33:/* add by dungnt 25.6.2012 */
				size = {
					w: 990,
					h: 200,
					template: '<div class="widgetAdnet wh990x200"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="#" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 34:/* add by dungnt 11.7.2012 */
				size = {
					w: 631,
					h: 90,
					template: '<div class="wh631x90 widgetHoz"><div class="headingWidget"><div class="Nobg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank" class="QCVer">&nbsp;</a></div></div></div><div class="widgetCont"></div></div>'
				};
				break;
			case 35:/* add by dungnt 11.7.2012 */
				size = {
					w: 320,
					h: 250,
					template: '<div class="widgetAdnet wh320x250"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="#" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			case 36:/* add by dungnt 11.7.2012 */
				size = {
					w: 300,
					h: 400,
					template: '<div class="widgetAdnet wh300x400"><div class="headingWidget"><div class="bg-adnet"><div class="textHead"><a href="http://adnet.vn" target="_blank">Mua quảng cáo</a><a href="#" class="logoAdnetBig">&nbsp;</a></div></div></div><div class="widgetCont"></div><span class="symbolB"></span> <span class="symbolR"></span></div>'
				};
				break;
			default:
				break;
		}
		return size;
	},
	get_rich_media_config: function(size_id) {
		var size = '';
		switch(size_id) {
			case 1:
				size = {
					item_height_1: 230,
					item_width_1: 260,
					item_delay_1: 15,
					widget_height_1: 270,
					widget_width_1: 274
				};
				break;
			case 2:
				size = {
					item_height_1: 230,
					item_width_1: 260,
					item_delay_1: 15,
					widget_height_1: 270,
					widget_width_1: 274,
					item_height_2: 300,
					item_width_2: 500,
					widget_height_2: 340,
					widget_width_2: 514
				};
				break;
		}
		return size;
	},
	gen_html_media_org: function(src, h, w, title, widget_id, target_url) {
		var extension = adnet_lib.get_url_extension(src);
		var html = '';
		switch(extension) {
			case 'swf':
				html = '<object height="' + h + '" width="' + w + '">';
				html += '<param name="movie" value="' + src + '" />';
				html += '<param name="quality" value="high" />';
				html += '<param name="flashVars" value="title=' + title + '&widget_id=' + widget_id + '" />';
				html += '<param name="allowScriptAccess" value="always" />';
				html += '<param value="transparent" name="wmode" />';
				html += '<embed src="' + src + '" height="' + h + '" width="' + w + '" flashvars="title=' + title + '&widget_id=' + widget_id + '"';
				html += ' allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer">';
				html += '</embed>';
				html += '</object>';
				break;
			case 'jpg':
			case 'jpeg':
			case 'gif':
			case 'png':
				html = '<a href="' + target_url + '" target="_blank" onclick="adnet_lib.rm_click(' + widget_id +');return true;"><img src="' + source + '" /></a>';
				break;
			case 'flv':
				html = '<object height="' + h + '" width="' + w + '">';
				html += '<param value="http://s0.adnet.vn/flash/adnet_player.swf" name="movie">';
				html += '<param value="high" name="quality"><param value="always" name="allowScriptAccess"><param name="wmode" value="transparent">';
				html += '<param value="img_url=' + encodeURIComponent(src) + '" name="flashVars">';
				html += '<embed height="' + h + '" width="' + w + '" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" ';
				html += 'flashvars="img_url=' + encodeURIComponent(src) + '" quality="high" src="http://s0.adnet.vn/flash/adnet_player.swf" />';
				html += '</object>';
				break;
		}
		return html;
	},
	gen_html_media: function(config) {
		var extension = adnet_lib.get_url_extension(config.source);
		var html = '';
		switch(extension) {
			case 'swf':
				html = '<object height="' + config.height + '" width="' + config.width + '">';
				html += '<param name="movie" value="' + config.source + '" />';
				html += '<param name="quality" value="high" />';
				html += '<param name="flashVars" value="title=' + config.title + '&widget_id=' + config.widget_id + '" />';
				html += '<param name="allowScriptAccess" value="always" />';
				html += '<param value="transparent" name="wmode" />';
				html += '<embed src="' + config.source + '" height="' + config.height + '" width="' + config.width + '" flashvars="title=' + config.title + '&widget_id=' + config.widget_id + '"';
				html += ' allowscriptaccess="always" wmode="transparent" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer">';
				html += '</embed>';
				html += '</object>';
				break;
			case 'jpg':
			case 'jpeg':
			case 'gif':
			case 'png':
				html = '<a href="' + config.target_url + '" target="_blank" onclick="adnet_lib.rm_click(' + config.widget_id +');return true;"><img src="' + config.source + '" /></a>';
				break;
			case 'flv':
				html = '<object height="' + config.height + '" width="' + config.width + '">';
				html += '<param value="http://s0.adnet.vn/flash/adnet_player.swf" name="movie">';
				html += '<param value="high" name="quality"><param value="always" name="allowScriptAccess"><param name="wmode" value="transparent">';
				html += '<param value="img_url=' + encodeURIComponent(config.source) + '" name="flashVars">';
				html += '<embed height="' + config.height + '" width="' + config.width + '" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" allowscriptaccess="always" ';
				html += 'flashvars="img_url=' + encodeURIComponent(config.source) + '" quality="high" src="http://s0.adnet.vn/flash/adnet_player.swf" />';
				html += '</object>';
				break;
		}
		return html;
	},
	
	/**	inserted by thoanhv; date: 2012-07-26; RM iTVC */
	build_rm_advanced: function(config) {
		var widget_html = jQuery('#adnet_widget_' + config.widget_id);
		if(widget_html.length == 0){			
			jQuery('body').append(widget_html);
			widget_html = jQuery('#adnet_widget_'+config.widget_id);
		}
		widget_html.attr('style','position: fixed; bottom:0; right: 0; z-index:1000000002; width: '+config.width+', height: '+config.height+'; margin: '+config.margin);
		widget_html.attr({
			'_widget_id': config.widget_id,
			'data_type': 4
		});
		var content = 	'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"'
						+		'width="'+config.width+'" height="'+config.height+'">'
						+		'<param name="movie" value="'+config.source+'" />'
						+		'<param name="quality" value="high" />'
						+		'<param name="allowScriptAccess" value="always" />'
						+		'<param name="flashvars" value="widget_id='+config.widget_id+'" />'
						+		'<param name="wmode" value="transparent" />'
						+		'<embed src="'+config.source+'" flashvars="widget_id='+config.widget_id+'" allowscriptaccess="always" wmode="transparent" quality="high" pluginspage="http://www.adobe.com/go/getflashplayer" type="application/x-shockwave-flash"'
						+		'width="'+config.width+'" height="'+config.height+'">'
						+		'</embed>'
						+'</object>';
		widget_html.html(content);
		return widget_html;
	},
	
	run_default: function(config) {
		adnet_lib.build_rm_advanced(config[0]);
		setTimeout(function() {
			adnet_lib.build_rm_advanced(config[1]);
		}, config[0].delay * 1000);
	},
	
	run_backward: function(config) {
		var objRM = adnet_lib.build_rm_advanced(config[1]);
		objRM.mouseover(function() {			
			var cookie = adnet_lib.getCookie('adnet.iTVC');
			if(cookie == 1 || adnet_lib.is_rmmin == 1) 
				return;			
			var startNumber = config[1].count_down;
			var objcountDown = jQuery('#adnet_countDown');
			if(startNumber > 0){								
				if(objcountDown.length == 0){
					objcountDown = '<div id="adnet_countDown" style="color: '+config[1].text_color+'; font-weight: bold; position: fixed; bottom: ' + Math.round(config[1].height - 60) + 'px !important; right: ' + Math.round(config[1].width - 60) + 'px !important; z-index:1000000003;"></div>';				
					jQuery('body').append(objcountDown);
					objcountDown = jQuery('#adnet_countDown');
					objcountDown.countDown({
						startFontSize: '30px',
						startNumber: startNumber,
						endNumber: 0,
						callBack: function(me) {
						}
					});
				}
			}
			clearTimeout(adnet_lib.delay);
			adnet_lib.delay = setTimeout(function() {
				objRM = adnet_lib.build_rm_advanced(config[0]);
				setTimeout(function() {
					objRM = adnet_lib.build_rm_advanced(config[1]);
				}, config[0].delay * 1000);
				adnet_lib.setCookie('adnet.iTVC',1,1);
				objcountDown.remove();
			}, startNumber * 1000);
		});
		objRM.mouseout(function() {
			var objcountDown = jQuery('#adnet_countDown');			
			if(objcountDown.length != 0){
				objcountDown.remove();
			}
			clearTimeout(adnet_lib.delay);
		});		
	},
	/** End RM iTVC*/
	
	trim_domain: function(url) {
		if (!url)
			return url;
		url = url.replace(/http(s)?:\/\/(w{3}(\d+)?\.)?/, '');
		url = url.replace(/\/.*?$/, '');
		url = url.replace(/:\d+$/, '');

		url =  url.toLowerCase();
		url = url.split('.');
		if(url.length > 3) {
			url.splice(0, url.length - 3);
		}
		return url.join('.');
	},
	rm_expand: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return;
		var data_type = Number(widget_html.attr('data_type'));
		if(data_type != 4) return;
		widget_html.trigger('action_expand');
	},
	rm_min: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return false;
		var data_type = Number(widget_html.attr('data_type'));
		if(data_type != 4) return false;
		return widget_html.trigger('action_min');
	},
	rm_advanced_min: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return false;
		widget_html.css({'z-index': 0});
		adnet_lib.is_rmmin = 1;
		var objcountDown = jQuery('#adnet_countDown');
		if(objcountDown.length != 0){
			objcountDown.remove();
		}
		clearTimeout(adnet_lib.delay);
	},
	rm_max: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return;
		var data_type = Number(widget_html.attr('data_type'));
		if(data_type != 4) return;
		widget_html.trigger('action_max');
	},
	rm_advanced_max: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return;
		widget_html.css({'z-index': 1000000002});
		adnet_lib.is_rmmin = 0;
	},
	rm_close: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return;
		var data_type = Number(widget_html.attr('data_type'));
		if(data_type != 4) return;
		widget_html.trigger('action_close');
	},
	rm_advanced_close: function(widget_id, is_zoom_in) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return;
		if(is_zoom_in && is_zoom_in == 1)
			adnet_lib.build_rm_advanced(adnet_lib.config_rm[1]);
		else
			widget_html.remove();
	},
	rm_click: function(widget_id) {
		var widget_html = jQuery('#adnet_widget_' + widget_id);
		if(!widget_html) return;
		var data_type = Number(widget_html.attr('data_type'));
		if(data_type != 4) return;
		widget_html.trigger('action_click');
	},
	skyscraper: function (element_id, is_left, e_h, e_w) {
		var e = document.getElementById(element_id);
		if (!e) {
			return false;
		}

		var w_w = 0,
		w_h = 0;

		if (document.body && document.body.offsetWidth) {
			w_w = document.body.offsetWidth;
		} else if (document.documentElement && document.documentElement.offsetWidth) {
			w_w = document.documentElement.offsetWidth;
		}
		if(window.navigator.userAgent.indexOf('MSIE') >= 0) {
			w_w -= 17;
		}
		w_h = window.innerHeight || (document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);

		if(arguments.length == 2) {
			e_w = e.offsetWidth;
			e_h = e.offsetHeight;
		}

		var dif = 0,
		fix_top = (w_h - e_h) / 2,
		cur_top = fix_top;

		/* Nếu chiều rộng, cao màn hình không đủ để hiển thị thì ẩn */
		if(typeof(ad_main_content_width) == 'undefined') {
			return false;
		}
		if ((w_w - ad_main_content_width) / 2 - 5 < e_w/* || w_h <= e_h*/) {
			e.style.display = 'none';
			return false;
		}
		e.style.display = 'block';
		e.style.position = 'absolute';
		e.style.height = e_h + 'px';
		e.style.width = e_w + 'px';

		/* Skyscraper luôn cách lề nội dung 5px */
		if (is_left) {
			e.style.left = ((w_w - ad_main_content_width) / 2 - 5 - e_w) + 'px';
		} else {
			e.style.right = ((w_w - ad_main_content_width) / 2 - 5 - e_w) + 'px';
		}
		e.style.top = fix_top + 'px';
		e.style.zIndex = 4;

		cur_top = parseInt(e.style.top);
		setInterval(function () {
			cur_top = parseInt(e.style.top);
			dif = (window.pageYOffset || document.body.scrollTop) + fix_top - cur_top;
			if (dif <= 2 && dif >= -2) {
				return;
			}
			e.style.top = (cur_top + dif / 4) + 'px';
		}, 50);
		
		return true;
	},
	make_click_layer: function (id, target_url, height, width, top, left, fn) {
		var ifrm = document.createElement('iframe');
		ifrm.setAttribute('id', 'adnet_ads_click_layer_' + id);
		ifrm.setAttribute('height', height);
		ifrm.setAttribute('width', width);
		ifrm.setAttribute('frameborder', '0');
		ifrm.setAttribute('style', 'z-index: 1000000002; border: none !important; margin: 0px !important; padding: 0px !important; position: absolute; top: ' + (top || 0) + 'px; left: ' + (left || 0) + 'px;');
		document.getElementById(id).appendChild(ifrm);

		ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
		ifrm.document.open();
		ifrm.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
			+ '<html>'
			+ '<head>'
			+ '<title>Adnet.VN Ads</title>'
			+ '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'
			+ '</head>'
			+ '<body style="margin:0px; padding: 0px;">'
			+ '<a href="' + target_url + '" target="_blank"><img style="border:none;height:' + height + 'px;width:' + width + 'px;" src="http://s0.adnet.vn/img/blank.gif" /></a>'
			+ '</body>'
			+ '</html>');
		ifrm.document.close();

		ifrm = document.getElementById('adnet_ads_click_layer_' + id);
		var a = ifrm.contentWindow.document.getElementsByTagName('a')[0];
		if (a.addEventListener) {
			a.addEventListener('click', fn, false);
		} else if (a.attachEvent) {
			a.attachEvent('onclick', fn);
		}
	},
	find_pos: function (el) {
		if (!el) return null;
		var curleft = curtop = i = 0;
		if (el.offsetParent) {
			do {
				curleft += el.offsetLeft;
				curtop += el.offsetTop;
				i++;
				el = el.offsetParent;
			} while (el && i < 20);
		}
		return [curleft, curtop];
	},
	on_window_load: function (fn) {
		if (window.addEventListener) {
			window.addEventListener('load', fn, false);
		} else if (window.attachEvent) {
			window.attachEvent('onload', fn);
		}
	},
	showPopup: function(siteId) {
		//return;//hot fix conflict chodientu & adnet
		this.init_ref();
		if(arguments.length == 0) return;		
			
		var c_name = 'adnet.popup';
		var cookie = this.getCookie(c_name);
		if(cookie) {
			adnet_lib.setCookie(c_name, siteId , 30); /* sliding cookie */
			return;
		}
		if(!this.pop_data) {
			var get_domain = encodeURIComponent(adnet_lib.trim_domain(adnet_lib.ref));			
			document.write(unescape("%3Cscript src='http://widget.adnet.vn/popdata.php?site_id=" + siteId + "&ref=" + get_domain + "' type='text/javascript'%3E%3C/script%3E"));			
			//ip_crawler
			/*var getClientIp = 'http://adnet.vn/geolocate.html';
			var crawlerIp = document.createElement('iframe');
			crawlerIp.setAttribute('height', '0');
			crawlerIp.setAttribute('width', '0');
			crawlerIp.setAttribute('frameborder', '0');
			crawlerIp.setAttribute('src', getClientIp);
			crawlerIp.setAttribute('style', 'display: none !important');
			document.getElementsByTagName('body')[0].appendChild(crawlerIp);*/
		}
	},
	AdsPop: function(siteId) {
		this.init_ref();
		if(arguments.length == 0) return;
		
		//check log click if exists					
		var c = this.getCookie('adnet.adspop.c');
		if(c){
			//Call log click
			var date = new Date(),
				d = date.getDate(), //day
				m = date.getMonth() + 1, //month
				y = date.getFullYear(), //year
				h = '20:00', //hours
				enable_time = new Date(m + '/' + d + '/' + y + ' ' + h).getTime(), //init time enable
				time_now = new Date().getTime();//time now
			if(enable_time >= time_now){	
				console.log('enable_time: ' + enable_time + '; time_now : ' + time_now);		
				var param = c.split(',');
				if(adnet_lib.sizeArray(param) == 4 && param[0] == siteId){				
					var c1 = this.getCookie('adnet.adspop.c_' + param[1]);
					if(c1){
						//none
					}else{
						adnet_lib.setCookie('adnet.adspop.c_' + param[1], 1, 100);				
						var url = "http://widget.adnet.vn/adspop.php?ltype=logc&site_id=" + param[0] + "&item_id=" + param[1] + "&widget_id=" + param[2] + "&sk=" + param[3]; 
						document.write(unescape("%3Cscript src='" + url + "' type='text/javascript'%3E%3C/script%3E"));		
					}
				}
			}
		}
		
		//init campaign		
		var items = {0: Array('17320','http://www.kfcvietnam.com.vn/#/DatHangTrucTuyen'),
				 	 1: Array('17189', 'http://www.kfcvietnam.com.vn/#/DatHangTrucTuyen')};
		var index = Math.floor(Math.random() * adnet_lib.sizeArray(items));		
		var get_domain = encodeURIComponent(adnet_lib.trim_domain(adnet_lib.ref));
		
		var c_name = 'adnet.adspop_' + items[index][0];
		var cookie = this.getCookie(c_name);		
		if(cookie) return;		
		
		//Request Landing Page
		var logImp = document.createElement('iframe');
		logImp.setAttribute('height', '0');
		logImp.setAttribute('width', '0');
		logImp.setAttribute('frameborder', '0');
		logImp.setAttribute('src', items[index][1]);
		logImp.setAttribute('style', 'display: none !important');
		//document.getElementsByTagName('body')[0].appendChild(logImp); remove because music
		
		//Call log imp
		document.write(unescape("%3Cscript src='http://widget.adnet.vn/adspop.php?ltype=logimp&site_id=" + siteId + "&item_id=" + items[index][0] + "&ref=" + get_domain + "' type='text/javascript'%3E%3C/script%3E"));		
	},
	AdsLogPop: function(siteId, sk) {	
		//Call log click
		document.onclick = function(e) {	
			if(!adnet_lib.ads_data) return;
			var ads = adnet_lib.ads_data;
			if(ads.item_id > 0){
			var target = e ? e.target : window.event.srcElement;			
				if (target.tagName == 'A' || target.parentNode.tagName== 'A') {						
					var c_name = 'adnet.adspop.c';					
					var param = siteId + ',' + ads.item_id + ',' + ads.widget_id + ',' + sk;
					adnet_lib.setCookie(c_name, param, 5);							
				}
			}
		};		
	},
	load_pop_data_finish: function(siteId, sk) {
		document.onclick = function(e) {
			if(!adnet_lib.pop_data || adnet_lib.is_poped) return;
			var target = e ? e.target : window.event.srcElement;			
			if (target.tagName == 'A' || target.parentNode.tagName== 'A') {				
				for(var i = 0, l = adnet_lib.pop_data.length; i < l; i++){
					var pageConfig = adnet_lib.pop_data[i];					
					/* ga_tracking */
					var ga_tracking = new Array();
					if(pageConfig.url.indexOf('utm_source') == -1)
						ga_tracking.push('utm_medium=' + encodeURIComponent(location.host));
					if(pageConfig.url.indexOf('utm_medium') == -1)
						ga_tracking.push('utm_medium=popup');
					if(pageConfig.url.indexOf('utm_campaign') == -1)
						ga_tracking.push('utm_campaign=' + encodeURIComponent(adnet_lib.trim_domain(pageConfig.url)));
					ga_tracking = ga_tracking.join('&');
					/* add params to url */
					//pageConfig.url += (pageConfig.url.indexOf('?') == -1 ? '?' : '&') + ga_tracking;//not work: http://1clickfm.com
					pageConfig.url = 'http://widget.adnet.vn/tpu_rd.php?site_id=' + siteId
					+ '&campaign_id=' + pageConfig.campaign_id
					+ '&ref=' + encodeURIComponent(adnet_lib.ref)
					+ '&targetURL=' + encodeURIComponent(pageConfig.url)
					+ '&sk=' + sk
					+ '&' + ga_tracking;				
					/*********/
					adnet_lib.pop_under(pageConfig);
				}
				adnet_lib.is_poped = true;
				var c_name = 'adnet.popup';
				adnet_lib.setCookie(c_name, siteId , 30); /* sliding cookie */
			}
		};
	},
	pop_under: function(pageConfig) {
		var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
		var popunder = is_chrome ? self.window.open(pageConfig.url) : self.window.open(pageConfig.url, '', 'height=' + (pageConfig.h || 800) + ',width=' + (pageConfig.w || 1024) + ',location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes');
		if (popunder) {
			popunder.blur();
			var ie_ver = this.getIEVersion();
			var bPopunder = (ie_ver > -1) && (ie_ver < 9);
			if (bPopunder) {
				/* classic popunder, used for old ie*/
				window.focus();
				try {
					opener.window.focus();
				}
				catch (err) { }
			} else {
				popunder.init = function(e) {
					with (e) {
						(function() {
							if (typeof window.mozPaintCount != 'undefined') {
								var x = window.open('about:blank');
								x.close();
							}

							try {
								opener.window.focus();
							}
							catch (err) { }
						})();
						}
				};
				popunder.params = {
					url: pageConfig.url
				};
				popunder.init(popunder);
			}
		}
	},
	sizeArray: function(obj) {
	    var size = 0, key = null;
	    for (key in obj) {
	        if (obj.hasOwnProperty(key)) size++;
	    }
	    return size;
	},
	getIEVersion: function(){
		var rv = -1; // Return value assumes failure.
		if (navigator.appName == 'Microsoft Internet Explorer') {
			var ua = navigator.userAgent;
			var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
			if (re.exec(ua) != null)
				rv = parseFloat( RegExp.$1 );
		}
		return rv;
	},
	alert: function(mes) {
		alert(mes);
	}
};

//inserted by thoanhv; date: 2012-07-28
jQuery.fn.countDown = function(settings,to) {
	settings = jQuery.extend({
		startFontSize: '36px',
		endFontSize: '12px',
		duration: 1000,
		startNumber: 10,
		endNumber: 0,
		callBack: function() { }
	}, settings);
	return this.each(function() {
		
		//where do we start?
		if(!to && to != settings.endNumber) { to = settings.startNumber; }
		
		//set the countdown to the starting number
		jQuery(this).text(to).css('fontSize',settings.startFontSize);
		
		//loopage
		jQuery(this).animate({
			'fontSize': settings.endFontSize
		},settings.duration,'',function() {
			if(to > settings.endNumber + 1) {
				jQuery(this).css('fontSize',settings.startFontSize).text(to - 1).countDown(settings,to - 1);
			}
			else
			{
				settings.callBack(this);
			}
		});
				
	});
};